<?php
header("Access-Control-Allow-Origin:*");
require("../lib/init.php");
require("../pojo/token.php");
$username = $_POST['username'];
$age = $_POST['age'];
$email = $_POST['email'];
$token = $_POST['token'];
if (empty($username) or empty($age) or empty($email) or empty($token)) {
    exit("缺少必要参数！");
}
if (!checkToken($token)) {
    $code = 400;
    $msg = "没有权限";
} else {
    $sql = "insert into employee (username,age,email) values ('$username','$age','$email')";
    if (!MQuery($sql)) {
        $code = 400;
        $msg = "添加失败！";
    } else {
        $code = 200;
        $msg = "添加成功！";
    }
}

echo json_encode(resultmsg($code, $msg));
